<!--  -->
<template>
    <div>
        <Card>
            <div slot="title" >
                <Button v-if="btnp.cggl_bgyplbiao_xzbgyp" @click="handleClickAdd" class="zh-hollow" type="primary" icon="plus-round">新增办公用品</Button>
                <Button v-if="btnp.cggl_bgyplbiao_dc" @click="modal_batch=true" style="marginLeft:25px;" class="zh-hollow" type="warning" >批量新增</Button>
            </div>
            <Form :model="formItem" :label-width="70">
                <Row :gutter="10" type="flex"  align="middle"  >
                    <Col span="8">
                        <FormItem label="名称">
                            <Input v-model="formItem.name" placeholder="办公用品名称" clearable></Input>
                        </FormItem>
                    </Col>
                    <Col span="8">
                        <FormItem label="供应商">
                            <Select v-model="formItem.supplier_uuid" filterable >
                                <Option  v-for="item in moreSupplierList" :value="item.uuid" :key="item.value">{{ item.name }}</Option>
                            </Select>
                        </FormItem>
                    </Col>
                    <Col span="8">
                        <FormItem label="类型">
                            <Select v-model="formItem.typeUuid" filterable>
                                <Option  v-for="item in moreTypeList" :value="item.uuid" :key="item.uuid">{{ item.name }}</Option>
                            </Select>
                        </FormItem>
                    </Col>
                
                    <Col span="8">
                        <FormItem label="状态">
                            <Select v-model="formItem.status" filterable>
                                <Option  v-for="item in stateList" :value="item.value" :key="item.value">{{ item.label }}</Option>
                            </Select>
                        </FormItem>
                    </Col>
                
                    <Col span="12">
                        <FormItem label="新增时间">
                            <DatePicker v-model="formItem.timeRange" format="yyyy-MM-dd HH:mm" type="datetimerange" placement="bottom-end" placeholder="请选择开始和结束时间"></DatePicker>
                        </FormItem>
                    </Col>
                </Row>
                <Row :gutter="10" >
                    <Col span="8" offset="16"  style="text-align:right;">
                        <Button @click='handleClickgetTable' class="zh-hollow" type="primary" icon="ios-search-strong">搜索</Button>
                        <!-- <Button v-if='btnp.cggl_bgyplbiao_dc' class="zh-hollow" type="warning" style="margin-left:25px;">导出EXCEL</Button> -->
                        <!-- <a style="margin-left:25px;" v-if="btnp.cggl_bgyplbiao_dc" :href="downLoadUrl" target="_blank"><Button  class="zh-hollow" type="warning"  > 导出EXCEL </Button></a> -->
                    </Col>
                
                </Row>
            </Form>
        </Card>
        <Card style="margin-top:10px;" :padding="0">
            <Table :loading="loading" border :columns="columns" :data="data"></Table>
            <Page  :total="total" show-total show-sizer :current.sync="formItem.pageNumber" @on-change="pageChange" @on-page-size-change="pageSizeChange"></Page>
        </Card>
        <Modal v-model="modal_batch" title="批量新增" class="zh-modal-form" class-name="vertical-center-modal">
            <div style="padding:15px 30px;">
                <p>从本地选择Excel格式的办公用品列表，批量导入办公用品。</p>
                <a :href="url_ofListTempDc"><Button type="text" style="color:#2d8cf0" >下载Excel模板</Button></a>
            </div>
            <div slot="footer" class="zh-flex zh-flex-5 excel" style="width:100%;">
                    <Button @clcik="modal_batch=false;" type="ghost">放弃操作</Button>
                    <Upload 
                    ref="upload"
                    :with-credentials="true"
                    :on-success="handleSuccessExcel"
                    :on-progress="handleProgressExcel"
                    :format="['xlsx','xls']"
                    :on-format-error="handleFormatErrorExcel"
                    :before-upload="handleBeforeUploadExcel"
                    :action="dr_url_bgyplb">
                        <Button type="primary" :loading="btnloading" class="zh-hollow">选择文件</Button>
                    </Upload>
            </div>
        </Modal>
        <Modal v-model="modal_info" :mask-closable='false' @on-ok="validate" :title="infotitle" :loading='saveloading' ok-text="保存" cancel-text="放弃操作" :class="classes">
            <Form v-if="infotype==='view'" :label-width="90" :model="information" style="padding:15px 30px;">
                <FormItem label="供应商：">
                    {{information.supplier}}
                </FormItem>
                <FormItem label="类型：">
                    {{information.type}}
                </FormItem>
                <FormItem label="名称：">
                    {{information.name}}
                </FormItem>
                <FormItem label="品牌：">
                    {{information.brand}}
                </FormItem>
                <FormItem label="型号：">
                    {{information.type_no}}
                </FormItem>
                <FormItem label="规格：">
                    {{information.description}}
                </FormItem>
                <FormItem label="包装与单价：">
                    <Row  v-for="(item,index) in information.other" :key="+index" style="padding: 5px">
                        <Col :span="12">
                            {{item.spec_name}}
                        </Col>
                        <Col :span="8" class="zh-flex">
                            <span>￥</span> {{item.price}}
                        </Col>  
                    </Row>
                </FormItem>
                <FormItem label="图片：">
                    <img v-if="!!information.pic.url" @click="handleView(information.pic.url)" :src="domain+information.pic.url" style="width:120px;height:120px">               
                </FormItem> 
                <FormItem label="备注：">
                   {{information.remarks}}
                </FormItem>                                                
            </Form>
            <Form v-else :label-width="80" :model="information" style="padding:15px 30px;">
                <FormItem label="供应商*">
                    <Input v-if="infotype=='edit'" readonly v-model="information.supplier"></Input>
                    <Select v-else v-model="information.supplier_uuid" filterable @on-change="supplierChange">
                        <Option  v-for="item in supplierList" :value="item.uuid" :key="item.uuid">{{ item.name }}</Option>
                    </Select>
                </FormItem>
                <FormItem label="类型*">
                    <Select v-model="information.type_uuid" filterable :disabled="information.supplier_uuid==''">
                        <Option  v-for="item in typeList" :value="item.uuid" :key="item.uuid">{{ item.name }}</Option>
                    </Select>
                </FormItem>
                <FormItem label="名称*">
                    <Input v-model="information.name" :maxlength="10"></Input>
                </FormItem>
                <FormItem label="品牌*">
                    <Input v-model="information.brand" ></Input>
                </FormItem>
                <FormItem label="型号*">
                    <Input v-model="information.type_no" ></Input>
                </FormItem>
                <FormItem label="规格*">
                    <Input v-model="information.description" :maxlength="20"></Input>
                </FormItem>
                <FormItem label="包装与单价*">
                    <Row  v-for="(item,index) in packprice" :key="'fixed'+index" style="padding: 5px">
                        <Col :span="12">
                            <Input v-model="item.spec_name" :maxlength="10"></Input>
                        </Col>
                        <Col :span="8" class="zh-flex">
                            <span>￥</span> 
                            <!-- <Input v-model="item.price" number ></Input> -->
                            <input type="text" class="ivu-input"  @input="newVal(index,item.price)"   v-model="item.price" >
                        </Col>  
                    </Row>
                    <Row  v-for="(item,index) in packprice2" :key="'variable'+index" style="padding: 5px">
                        <Col :span="12"><Input v-model="item.spec_name"></Input></Col>
                        <Col :span="8" class="zh-flex">
                            <span>￥</span>
                            <!-- <Input number v-model="item.price"></Input> -->
                            <input type="text" class="ivu-input"  @input="newVal2(index,item.price)"   v-model="item.price" >
                        </Col>
                        <Col :span="4" style="textAlign:center;"><Icon :size="25" @click.native="removePackprice(index)" style="color:#ed3f14;cursor；pointer" type="ios-close-outline"></Icon></Col>
                    </Row>
                    <div style="margin-top:10px;paddingLeft:15px;">
                        <Tooltip content="新增一种包装">
                            <Icon :size="25" @click.native="addPackprice" style="color:#2d8cf0;cursor；pointer" type="ios-plus-outline"></Icon>
                        </Tooltip>
                    </div>
                </FormItem>
                <FormItem label="图片">
                    <template v-if="!!information.pic.url">
                        <div class="upload-wrap" v-if="information.pic.status === 'finished'">
                            <img :src="domain+information.pic.url" style="display:block;width:120px;height:120px;">
                            
                            <div class="upload-cover" style="width:120px;height:120px;">
                                    <div class="iconBox">
                                        <Icon type="ios-eye-outline" @click.native="handleView(information.pic.url)"></Icon>
                                        <Icon type="ios-trash-outline" @click.native="handleRemove(information.pic.url)"></Icon>
                                    </div> 
                                    
                                </div>
                        </div>
                        <template v-else>
                            <Progress v-if="information.pic.showProgress" :percent="information.pic.percentage" hide-info></Progress>
                        </template>
                    </template>
                    <template v-else>
                        <Upload
                            ref="upload"
                            :default-file-list="defaultList"
                            :show-upload-list="false"
                            :on-success="handleSuccess"
                            :format="['jpg','jpeg','png']"
                            :max-size="2048"
                            :on-format-error="handleFormatError"
                            :on-exceeded-size="handleMaxSize"
                            :before-upload="handleBeforeUpload"
                            type="drag"
                            :data="upLoadData"
                            action=" http://upload.qiniup.com"
                            style="display: inline-block;width:120px;height:120px;">
                            <div style="width:120px;height:120px;line-height:120px;">
                                <Icon type="ios-plus-empty" :size='40'></Icon>
                            </div>
                        </Upload>
                        <p>请上传jpg/png格式，小于2M的图片。</p>
                    </template>
                   
                </FormItem> 
                <FormItem label="备注">
                    <Input :maxlength="20" v-model="information.remarks" ></Input>
                </FormItem>                                                
            </Form>
        </Modal>
        <Modal title="查看图片" v-model="look_pic_wrap.look_pic" class="zh-modal-form no_footer_modal">
            <!-- <p slot="header" >查看凭证</p> -->
            <img style="width:100%;" :src="domain+look_pic_wrap.src" alt="">
        </Modal>
    </div>
</template>

<script>
import {url_ofListDc,url_ofListTempDc,dr_url_bgyplb} from '@/libs/downLoadUrl'
import accounting from 'accounting'
import util from '@/libs/util.js'
// import {getServiceAll} from '@/libs/system.js'
// import {getAllServiceByCustomer} from '@/libs/get.js'
import {getQiniuToken} from '@/libs/get.js'
import {
    getPurOffList,
    purOffFreezon,
    deletePurOffList,
    saveOffPurList,
    getOffTypeList,
    getVoucherProvideList
} from '@/libs/purchase.js'
export default {
    name:'',
    data () {
        return {
            url_ofListTempDc:url_ofListTempDc,
            btnloading:false,
            dr_url_bgyplb:dr_url_bgyplb,
            downLoadUrl:url_ofListDc,
            saveloading:true,
            defaultList:[],
            domain:this.$store.state.app.domain,
            upLoadData:{
                token:'',
                unique_names: true,
                domain:this.$store.state.app.domain
            },
            user_type:'',
            userUuid:'',
            btnp:{},
            btn:{
                cggl_bgyplbiao_xzbgyp:false,
                cggl_bgyplbiao_dc:false,
                cggl_bgyplbiao_dc:false,
                cggl_bgyplbiao_xq:false,
                cggl_bgyplbiao_bj:false,
                cggl_bgyplbiao_tzgy:false,
                cggl_bgyplbiao_hfgy:false,
                cggl_bgyplbiao_sc:false,
            },
            uploadList:[],
            look_pic_wrap:{
                look_pic:false,
                src:''
            },
            packprice:[
                {
                    spec_name:'',
                    price:''
                },
                {
                    spec_name:'',
                    price:''
                }
            ],
            packprice2:[],
            information:{
                uuid:'',
                name:'',
                supplier_uuid:'',
                supplier:'',
                type_uuid:'',
                type:'',
                brand:'',
                type_no:'',
                description:'',
                spec_name:'',
                price:'',
                remarks:'',
                pic:{
                    name:'',
                    url:'',
                    status:'',
                    showProgress:true,
                    percentage:0
                },
                other:[
                    {
                        spec_name:'',
                        price:''
                    }
                ]
            },
            classes:'',
            modal_info:false,
            infotype:'',//add,edit,view
            infotitle:'',
            loading:true,
            total:0,
            modal_batch:false,
            timeRange:[],
            formItem:{
                name:'',
                supplier_uuid:'全部',
                typeUuid:'全部',
                status:'全部',
                pageNumber:1,
                pageSize:10
            },
            moreTypeList:[],
            typeList:[],
            moreSupplierList:[],
            supplierList:[],
            stateList:[
                {
                    label:'全部',
                    value:'全部'
                },{
                    label:'供应中',
                    value:'1'
                },{
                    label:'停止供应',
                    value:'0'
                }
            ],
            columns:[
                {
                    key:'supplier_name',
                    title:'供应商',
                    fixed:'left',
                    minWidth:120
                },
                {
                    key:'type_name',
                    title:'类型',
                    minWidth:100
                },
                {
                    key:'name',
                    title:'名称',
                    minWidth:100
                },
                {
                    key:'brand',
                    title:'品牌',
                    minWidth:80
                },
                {
                    key:'type_no',
                    title:'型号',
                    minWidth:80
                },
                {
                    key:'statusNm',
                    title:'状态',
                    minWidth:100,
                    align:'center'
                },
                {
                    key:'time',
                    title:'新增时间',
                    minWidth:150,
                    align:'center'
                },

                {
                    key:'action',
                    title:'操作',
                    align:'center',
                    fixed:'right',
                    minWidth:180,
                    render:(h,params)=>{
                        let status=params.row.status;
                        let uuid=params.row.uuid;
                        return h('div',[
                            h('Button',{
                                props:{
                                type:'text',
                                size:'small'
                                },
                                style:{
                                color:'#2D8CF0',
                                    display:this.btnp.cggl_bgyplbiao_xq?'inline-block':'none'
                                },
                                on:{
                                click:()=>{
                                   this.modal_info=true;
                                    this.infotype='view';
                                    this.gotoEdit(params.row);
                                    
                                }
                                }
                            },'详情'), 
                            h('Button',{
                                props:{
                                type:'text',
                                size:'small'
                                },
                                style:{
                                color:'#2D8CF0',
                                display:this.btnp.cggl_bgyplbiao_bj?'inline-block':'none'
                                },
                                on:{
                                click:()=>{
                                    this.modal_info=true;
                                    this.infotype='edit';
                                    this.gotoEdit(params.row);
                                    this.getType(params.row.supplier_uuid);
                                }
                                }
                            },'编辑'), 
                            h('Button',{
                                props:{
                                type:'text',
                                size:'small'
                                },
                                style:{
                                color:'#2D8CF0',
                                display:this.btnp.cggl_bgyplbiao_tzgy?status=='1'?'inline-block':'none':'none'
                                },
                                on:{
                                    click:()=>{
                                        let config={
                                            title:'停止供应',
                                            content:'停止供应后，不能再对该项办公用品进行申领。',
                                            okText:'停止供应',
                                            cancelText:'放弃操作',
                                            onOk:()=>{
                                                this.freezon(uuid,'freezon')
                                            }
                                        }
                                        this.$Modal.confirm(config)                                                                        
                                    }
                                }
                            },'停止供应'), 
                            h('Button',{
                                props:{
                                type:'text',
                                size:'small'
                                },
                                style:{
                                color:'#2D8CF0',
                                display:this.btnp.cggl_bgyplbiao_hfgy?status=='0'?'inline-block':'none':'none'
                                },
                                on:{
                                click:()=>{
                                    let config={
                                        title:'恢复供应',
                                        content:'恢复供应后，可以继续对该项办公用品进行申领。',
                                        okText:'恢复',
                                        cancelText:'放弃操作',
                                        onOk:()=>{
                                            this.freezon(uuid,'unfreezon')
                                        }
                                    }
                                    this.$Modal.confirm(config)
                                    
                                }
                                }
                            },'恢复供应'),                                                                                                                
                            h('Button',{
                                props:{
                                type:'text',
                                size:'small'
                                },
                                style:{
                                color:'#EA0000',
                                display:this.btnp.cggl_bgyplbiao_sc?status=='0'?'inline-block':'none':'none'
                                },
                                on:{
                                click:()=>{
                                    let config={
                                    title:'删除办公用品',
                                    content:'删除后该办公用品无法查询，也无法恢复。',
                                    okText:'删除',
                                    cancelText:'放弃操作',
                                    onOk:()=>{
                                        this.delete(uuid);
                                    }
                                    }
                                    this.$Modal.confirm(config)
                                }
                                }
                            },'删除')
                        ])
                    }
                }
            ]    ,
            data:[] 
        };
    },
    methods:{
        handleSuccessExcel(res, file){
            if(res.code==200){
                this.$Notice.success({
                    desc:res.msg
                });
                this.modal_batch=false;
                this.getTable();
            }else{
                this.$Notice.error({
                    desc:res.msg
                })
            }
            this.btnloading=false;
        },
        handleProgressExcel(){
            this.btnloading=true;
        },
        handleBeforeUploadExcel(){

        },
        handleFormatErrorExcel (file) {
            this.$Notice.warning({
                title: '文件格式错误',
                desc: '请选择 xlsx 或 xls 格式的文件'
            });
        },
        newVal(index,val){
            let price=util.amount(val);//accounting.formatMoney(accounting.unformat(util.amount(val)),'',2,',');
            this.packprice[index].price=price;
        },
        newVal2(index,val){
            let price=util.amount(val);//accounting.formatMoney(accounting.unformat(util.amount(val)),'',2,',');
            this.packprice2[index].price=price;
        },
        pageSizeChange(size){
            //回到第一页
            this.formItem.pageNumber=1;
            this.formItem.pageSize=size;
            this.getTable();
        },
        pageChange(number){
            this.formItem.pageNumber=number;
            this.getTable();
        },
        handleClickgetTable(){
            this.formItem.pageNumber=1;
            this.getTable();
        },
        async getTable(){
            this.loading=true;
            let form=JSON.parse(JSON.stringify(this.formItem));
            for(let key in form){
                if(form[key]==='全部'){
                form[key]='';
                }
            }
            if(!!this.timeRange[0]&&this.timeRange.length>0){
                form.startTime=util.time1(this.timeRange[0]);
                form.endTime=util.time1(this.timeRange[1]);
            }
            
            let res=await getPurOffList(form);
            if(res.status===200){
                let response=res.data;
                if(response.code===200){
                    this.total=response.data.total;
                    this.data=response.data.rows.map(item=>{
                        item.time=item.created.slice(0,16);
                        return item
                    })
                    this.loading=false;
                    this.downLoadUrl=`${url_ofListDc}${util.pjArgu(form)}`;
                }else{
                    this.$Notice.error({
                        desc:response.msg
                    });
                }
            }else{
                this.$Notice.error({
                    title: '请求失败'
                });
            } 
        },
        async freezon(uuid,flag){
            let res=await purOffFreezon(uuid,flag);
            let response=res.data;
            if(response.code==200){
                this.$Notice.success({
                    desc:flag=='freezon'?'已停止供应':"已恢复"
                });
                this.getTable();
            }else{
                this.$Notice.error({
                    desc:response.msg
                })
            }
        },
        async delete(uuid){
            let res=await deletePurOffList(uuid);
            let response=res.data;
            if(response.code==200){
                this.$Notice.success({
                    desc:"已删除"
                });
                this.handleClickgetTable();
            }else{
                this.$Notice.error({
                    desc:response.msg
                })
            }
        },
        supplierChange(value){
            this.getType(value)
        },
        async getType(uuid){
            let res=await getOffTypeList(uuid);
            let response=res.data;
            if(response.code==200){
                this.typeList=response.data;
            }else{
                this.$Notice.error({
                    desc:response.msg
                })
            }
        },
        async getMoreType(){
            let res=await getOffTypeList();
            let response=res.data;
            if(response.code==200){
                this.moreTypeList=[{name:'全部',uuid:'全部'},...response.data];
            }else{
                this.$Notice.error({
                    desc:response.msg
                })
            }
        },
        async getProvide(){
            let res=await getVoucherProvideList('office');
            let response=res.data;
            if(response.code==200){
                this.moreSupplierList=[{name:'全部',uuid:'全部'},...response.data];
                this.supplierList=response.data;
            }else{
                this.$Notice.error({
                    desc:response.msg
                })
            }
        },
    
        gotoEdit(obj){
            this.information={
                uuid:obj.uuid,
                name:obj.name,
                supplier_uuid:obj.supplier_uuid,
                supplier:obj.supplier_name,
                type_uuid:obj.type_uuid,
                type:obj.type_name,
                brand:obj.brand,
                type_no:obj.type_no,
                description:obj.description,
                spec_name:'',
                price:'',
                remarks:obj.remarks,
                pic:{
                    name:'',
                    url:!!obj.image_url?obj.image_url:'',
                    status:!!obj.image_url?'finished':'',
                    showProgress:true,
                    percentage:0
                },
                other:obj.MBSpecAndPrice.map(item=>{
                    item.price=accounting.formatMoney(accounting.unformat(util.amount(item.price)),'',2,',');
                    return item
                })
            };
            if(obj.MBSpecAndPrice.length>2){
                this.packprice=[obj.MBSpecAndPrice[0],obj.MBSpecAndPrice[1]];
                this.packprice2=obj.MBSpecAndPrice.slice(2);
            }else if(obj.MBSpecAndPrice.length==2){
                this.packprice=obj.MBSpecAndPrice;
            }else if(obj.MBSpecAndPrice.length==1){
                this.packprice[0]=obj.MBSpecAndPrice[0];
            }
        },
        async save(arr){
            let form =JSON.parse(JSON.stringify(this.information));
            form.spec_name=arr.map(item=>{
                return item.spec_name
            }).join(',');
            form.price=arr.map(item=>{
                return item.price
            }).join(',');
            form.image_url=form.pic.url;
            let res=await saveOffPurList(form);
            let response=res.data;
            if(response.code==200){
                this.$Notice.success({
                    desc:'已保存'
                });
                this.getTable();
                this.modal_info=false;
            }else{
                this.$Notice.error({
                    desc:response.msg
                })
            }
        },
        async validate(){
            let p=[...this.packprice,...this.packprice2].filter(item=>{
                if(item.spec_name!=''&&item.spec_name!=''){
                    return item
                }
            });

            if(this.information.supplier_uuid.length<=0){
                this.$Notice.error({
                    desc:'请选择供应商'
                })
            }else if(this.information.type_uuid.length<=0){
                this.$Notice.error({
                    desc:'请选择类型'
                })
            }else if(this.information.name==''){
                this.$Notice.error({
                    desc:'请输入办公用品名称'
                })
            }else if(this.information.name.length<2){
                this.$Notice.error({
                    desc:'名称至少2个字符'
                })
            }else if(this.information.brand==''){
                this.$Notice.error({
                    desc:'请输入办公用品品牌'
                })
            }else if(this.information.brand.length<2){
                this.$Notice.error({
                    desc:'品牌至少2个字符'
                })
            }else if(this.information.type_no==''){
                this.$Notice.error({
                    desc:'请输入办公用品型号'
                })
            }else if(this.information.type_no.length<2){
                this.$Notice.error({
                    desc:'型号至少2个字符'
                })
            }else if(p.length<=0){
                this.$Notice.error({
                    desc:'至少输入1种包装'
                })
            }else{
                await this.save(p);
            }
            let that=this;
            this.saveloading=false;
            setTimeout(()=>{
                that.saveloading=true;
            },500)
        },

        removePackprice(index){
            this.packprice2.splice(index,1);
        },
        addPackprice(){
            this.packprice2.push({
                spec_name:'',
                price:''
            })
        },
        handleClickAdd(){
            this.modal_info=true;
            this.infotype='add';
            
        },
        async qiniuToken(){
            let res=await getQiniuToken();
            let response=res.data;
            if(response.code===200){
                this.upLoadData.token=JSON.parse(response.data).uptoken;
            }else{
                this.$Notice.error({
                    title: '请求出错',
                    desc:response.msg
                });
            }
        },
        handleView(img){
            this.look_pic_wrap.look_pic=true;
            this.look_pic_wrap.src=img
        },
        handleRemove(img){
            this.uploadList=[];
            this.information.pic={
                name:'',
                url:'',
                status:'',
                showProgress:true,
                percentage:0
            }
        },
        handleSuccess (res, file) {
            this.information.pic=file;
            this.information.pic.url=res.hash;
        },
        handleFormatError (file) {
            this.$Notice.warning({
                title: '图片格式错误',
                desc: '请选择 jpg 或 png 格式的图片'
            });
        },
        handleMaxSize (file) {
            this.$Notice.warning({
                title: '图片过大',
                desc: '请选择文件大小小于2M的图片'
            });
        },
        handleBeforeUpload (file) {
            const check = this.$refs.upload.fileList.length < 2;
            if (!check) {
                this.$Notice.warning({
                    title: '一次只能上传一张'
                });
            }
            return check;
        }
    },
    watch:{
        infotype:function(){
            this.infotitle=this.infotype==="add"?'新增办公用品':this.infotype==='edit'?'编辑办公用品信息':'办公用品详情';
            this.classes=this.infotype==="view"?'no_footer_modal':'';
        },
        modal_info:function(){
            if(!this.modal_info){
                this.typeList=[];
                this.information={
                    uuid:'',
                    name:'',
                    supplier_uuid:'',
                    supplier:'',
                    type_uuid:'',
                    type:'',
                    brand:'',
                    type_no:'',
                    description:'',
                    spec_name:'',
                    price:'',
                    remarks:'',
                    pic:{
                        name:'',
                        url:'',
                        status:'',
                        showProgress:true,
                        percentage:0
                    },
                    other:[
                        {
                            spec_name:'',
                            price:''
                        }
                    ]
                };
                this.packprice=[
                    {
                        spec_name:'',
                        price:''
                    },
                    {
                        spec_name:'',
                        price:''
                    }
                ];
                this.packprice2=[];
            }else{
                this.qiniuToken();
            }
        }
    },
    created(){
        util.isCustomer(this);
        this.btnp=util.bpower(this,this.btn);
        this.getTable();
        this.getMoreType();
        this.getProvide();
    },

}

</script>
<style lang='scss' >
.upload-wrap{
    width:120px;
    height:120px;
    text-align:center;
    position: relative;
    box-shadow: 0 1px 1px rgba(0,0,0,.2);
}
.iconBox{
    display:inline-block;
    position:absolute;
    top:50%;
    left:50%;
   transform: translateX(-50%) translateY(-50%);

}
.upload-cover{
    display: none;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,.6);
    i{
        color: #fff;
        font-size: 30px;
        cursor: pointer;
        margin: 0 10px;
    }
}
.upload-wrap:hover .upload-cover{
    display: block;
}
.excel .ivu-upload-list{
    display:none!important;
}
</style>